package com.anjho.pojo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "publisher")
@NamedQueries(value = {
		@NamedQuery(name = "Publisher.getPublisherList", query = "SELECT p FROM Publisher p"),
		@NamedQuery(name = "Publisher.getPublisherByPucode", query = "SELECT p FROM Publisher p WHERE p.pucode = :pucode")
})
public class Publisher implements Serializable {

	private static final long serialVersionUID = 7249816599168099617L;

	@Id
	@Column(name="pucode")
	@OneToMany(mappedBy="publisher")
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	private int pucode;

	@Column(name="description", nullable=false, length=50)
	private String description;
	
	public Publisher() {
		super();
	}
	
	public Publisher(int pucode, String description) {
		this.pucode = pucode;
		this.description = description;
	}
	
	public void setPucode(int pucode){
		this.pucode = pucode;
	}

	public int getPucode() {
		return pucode;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + pucode;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Publisher other = (Publisher) obj;
		if (pucode != other.pucode)
			return false;
		return true;
	}

}
